package cn.kgc.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 课工场
 * @date 2025/1/15
 * @description
 */
@RestController
@RequestMapping("nacosConfig")
@RefreshScope
@Slf4j
public class NacosConfigController {


    @Value("${uname}")
    private String username;
    @Value("${age}")
    private Integer age;

    @GetMapping("m1")
    public String  method1(){
        return  "NacosConfigController method1 ok  username="+username+" age="+age;
    }

/*
*   如何通过日志方式 打印信息  用于程序调试
*   日志打印常用的级别
*      debug   info  warn  error
*    日志级别越低 打印的日志信息越多   springboot中默认级别 info
* */
    @GetMapping("m2")
    public String  method2(Integer id){

        log.debug("debug id={}",id);
        log.info("info id={}",id);
        log.warn("warn id={}",id);
        log.error("error id={}",id);

        return  "NacosConfigController method1 ok  username="+username+" age="+age;
    }
}
